
<?php if (isset($_POST['ID'])) {
	$ID = $_POST['ID'];

	require_once __DIR__ . '/db_bb_connect.php';

	$sql = "SELECT category, text, visibility
	FROM attentionpointsplayers
	WHERE ID = $ID";

	$result = $db->query($sql);
	$row = $result->fetch_assoc();

	$category = $row['category'];
	$text = $row['text'];
	$visibility = $row['visibility'];

?>

<br><br>
<div class="row">

<div class="col-md-6">

<div class="text-center"><h4>Edit Attention Point for <?= $firstname ?> <?= $lastname ?> </h4></div>

<form>

<input type="hidden" name="ID" value="<?= $ID ?>">

<select class="form-control" name="category">
         	<option value="<?= $category ?>" selected="selected"><?= ucfirst($category) ?> was selected</option>
         	<option value="game">Game</option>
         	<option value="training">Training</option>
          	<option value="general">General</option>
</select>
<br><br>
<select class="form-control" name="visibility">
  <option value="<?= $visibility ?>" selected="selected"><?= ucfirst($visibility) ?> was selected</option>
  <option value="no">No</option>
  <option value="yes">Yes</option>
</select>

<br><br>
 <textarea class="form-control" rows="4"  name="text"><?= $text ?></textarea> 
<br><br>

	<button type="submit" class="btn btn-success submitedit"> Submit </button>
  </form>
</div>

</div>

<script type="text/javascript">
	
	$(".submitedit").on("click", function(e) {
		postData = $(this.form).serialize();
		$.ajax({
 			type: "POST",
  			url: "./includes/handlers/playerpointsofattention_edit_handler.php",
  			data: postData,
  			success: function(data) { 
  				$("#fullplayerprofile").html(data);				
  			},
  			error: function (xhr, status, error) {
  				alert(xhr.responseText);
  			}
  		}); 
		e.preventDefault();		
});

</script>

<?php } ?>